<template>
    <div class="post">
        <div style="display: flex; margin-bottom: 2rem;">
            <h1>{{ spotName }}</h1>
            <span class="iconfont icon-eye">{{ viewCount }}</span>
        </div>
        <div class="typo">
            <MdPreview :modelValue="props.spotContent" />
        </div>
    </div>

</template>

<script setup>
import { MdPreview } from 'md-editor-v3';
// preview.css相比style.css少了编辑器那部分样式
import 'md-editor-v3/lib/preview.css';

const props = defineProps({
    spotContent: {
        type: String,
        default: ""
    },
    spotName: {
        type: String,
        default: ""
    },
    viewCount: {
        type: Number,
    }
})

</script>


<style lang="scss" scoped>
.post {
    width: 100%;
    padding: 2rem;
    background: #fff;
    border-radius: 1rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.2);
    border: #eee solid .1rem;

    span {
        display: flex;
        align-items: center;
        margin-left: 2rem;
        font-size: 1.5rem;
    }

    h1 {
        font-size: 3rem;
        font-weight: 400;
    }
}

:deep(div.default-theme p) {
    line-height: 2.5;
    padding: 1rem 0;
    font-size: 1.6rem;

}

:deep(div.default-theme img) {
    height: 100%;
    width: 100%;
}

:deep(.default-theme code) {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
}

:deep(.default-theme pre) {
    max-width: 100%;
    overflow: auto;
    padding: 1em;
    background: #f5f5f5;
    border-radius: 10px;
}

:deep(.md-editor-preview-wrapper) {
    padding: 0;
}

@media (max-width:768px) {
    .post-container .post {
        padding: 1rem;
    }
}
</style>